<!--
 * @Author: 吴让坤
 * @Date: 2023-03-18 23:51:10
 * @LastEditTime: 2023-05-17 15:26:21
 * @Description: 无线滚动
-->
<script setup lang='ts'>
import InfiniteScroll from './components/infinite-scroll.vue';
const list = ref<number[]>([])
const loading = ref(true)

const fetchlist = () => {
  setTimeout(() => {
    for (let index = 0; index < 20; index++) {
      list.value.push(index)
    }
    loading.value = false
  }, 2000);
}
const load = () => {
  loading.value = true
  console.log('load');
  fetchlist()
}
onMounted(() => {
  fetchlist()
})
</script>

<template>
  <div class="p-24px">
    <InfiniteScroll :loading="loading" @load="load">
      <div v-for="item in list">{{ item }}</div>
    </InfiniteScroll>
  </div>
</template>
